package com.wisdudu.blank.data.source.remote.client.retrofit.client;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.lang.reflect.Modifier;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by qyf on 2016/8/17.
 */

public enum RetrofitClient {
    INSTANCE;
    private final Retrofit.Builder retrofitBuilder;

    RetrofitClient() {
        Gson gson = new GsonBuilder().setDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'")
                .excludeFieldsWithModifiers(Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC)
                .create();

        retrofitBuilder = new Retrofit.Builder()
                //设置OKHttpClient
                .client(OkClient.INSTANCE.getOkHttpClient())
                //Rx
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                //String转换器
                .addConverterFactory(StringConverterFactory.create())
                //gson转化器
                .addConverterFactory(GsonConverterFactory.create(gson));
    }

    public Retrofit.Builder getRetrofitBuilder() {
        return retrofitBuilder;
    }
}
